In recent years, high dynamic range (HDR for short) technologies are becoming mature and widely applied to image and video encoding and decoding technologies. Compared with an ordinary image, an HDR image can provide a wide dynamic range and more image details, and can better reflect a visual effect in a real environment. In an HDR image, to record more image luminance information, instead of a conventional integer-bit (N-bit) image representation format, a 16-bit or 32-bit floating-point number is used to record luminance information. Because the image representation format is different from the conventional integer-bit representation manner, particular preprocessing and postprocessing need to be performed during HDR video encoding.
Because an HDR video finally needs to be quantized as integer-bit data for subsequent encoding, considering that a dynamic range of the HDR video is far greater than that of the integer-bit data, a great loss may be caused to information about an HDR source if linear quantification is directly performed. Therefore, an HDR video represented by using a floating-point number needs to be converted by using a conversion function. A form for such conversion may be nonlinear conversion, to protect luminance sections requiring special protection, or may be conversion in another form, for example, tone mapping (English: Tone Mapping).
FIG. 1 is a typical flowchart of preprocessing and encoding of an HDR video.
As shown in FIG. 1, first, an HDR video represented by using a floating-point number is processed by using a conversion function, to obtain R′G′B′ data. Then, the R′G′B′ data is converted to an image of a 4:4:4 YCbCr format, and then the floating-point number is converted to an integer by a quantization module. To minimize a loss of an HDR source, an HDR source is usually quantized as fixed-length-bit integer data, for example, 10-bit integer data. Finally, the 4:4:4 YCbCr data is converted to 4:2:0 YCbCr data to complete the preprocessing process. After the preprocessing, the floating-point-number HDR data has been converted to the integer-data (for example, 10-bit) 4:2:0 YCbCr data applicable to conventional video encoding. In this case, the 4:2:0 YCbCr data is then encoded by an encoder that uses a conventional video encoding technology, to obtain an encoded bitstream. The fixed-length-bit integer may be 16 bits, 12 bits, 10 bits, or 8 bits. For simplicity, 10 bits are used as an example below for description.
FIG. 2 is a flowchart of corresponding decoding and postprocessing.
As shown in FIG. 2, first, on a decoder side, an encoded bitstream is decoded by a decoder that uses a conventional video decoding technology, to obtain reconstructed 4:2:0 10-bit YCbCr data. Then, 10-bit reverse quantization is performed on the 4:2:0 10-bit YCbCr data to obtain data of a 16-bit or 32-bit floating-point number format. Afterward, the data of the 16-bit or 32-bit floating-point number format is converted to data of an R′G′B′ format. Finally, the data of the R′G′B′ format is processed by using a reverse conversion function to obtain an HDR image or video.
A conversion function used in an existing HDR encoding technology is a global function. That is, a video is nonlinearly processed by using a uniform conversion function. Because a video includes images falling within different luminance ranges, and luminance information ranges of different areas of an image are not the same, using a single global conversion function cannot consider luminance characteristics of all images in the video and all areas in the images, affecting effects of HDR video encoding and decoding. In addition, currently, in an HDR video encoding and decoding method, to minimize distortion of an HDR signal source, a 10-bit integer encoding and decoding method is used. Design costs and complexity of a 10-bit integer codec are both greater than those of an 8-bit integer encoding and decoding method, increasing implementation costs of an HDR video codec.